]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Make gnome-shell-extension-prefs a binary executable
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 6 Dec 2013 20:20:03 +0000 (21:20 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 16 Jan 2014 14:33:01 +0000 (09:33 -0500)
Since commit 1ebb162a00bf6c4b0 moved JS sources into resources,
the extension-prefs tool was broken. To fix it, we would either
need to generate an external GResource in addition to the generated
C code and teach gjs-console about loading it before evaluating
the script, or turn gnome-shell-extension-prefs into a binary with
the JS resources compiled in.

https://bugzilla.gnome.org/show_bug.cgi?id=722334

src/Makefile.am
src/gnome-shell-extension-prefs.c [new file with mode: 0644]
src/gnome-shell-extension-prefs.in [deleted file]

index 1c0d377e499464b1fdd9261c1f096125ad31cdb4..f25d475c819d8528298d399afd31ba1c654d8282 100644 (file)
@@ -29,11 +29,9 @@ CLEANFILES += $(service_DATA)
 
 CLEANFILES += $(gir_DATA) $(typelib_DATA)
 
-bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-extension-prefs \
-              gnome-shell-perf-tool
-EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-extension-prefs.in \
-             gnome-shell-perf-tool.in
-bin_PROGRAMS = gnome-shell
+bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-perf-tool
+EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-perf-tool.in
+bin_PROGRAMS = gnome-shell gnome-shell-extension-prefs
 
 if HAVE_MUTTER_WAYLAND
 bin_PROGRAMS += gnome-shell-wayland
@@ -54,9 +52,6 @@ generated_script_substitutions = \
 gnome-shell-extension-tool: gnome-shell-extension-tool.in Makefile
        $(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
 
-gnome-shell-extension-prefs: gnome-shell-extension-prefs.in Makefile
-       $(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
-
 gnome-shell-perf-tool: gnome-shell-perf-tool.in Makefile
        $(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
 
@@ -209,6 +204,13 @@ gnome_shell_wayland_LDADD = libgnome-shell-wayland.la libgnome-shell-js.la $(GNO
 gnome_shell_wayland_DEPENDENCIES = libgnome-shell-wayland.la
 endif HAVE_MUTTER_WAYLAND
 
+gnome_shell_extension_prefs_SOURCES = gnome-shell-extension-prefs.c \
+       $(top_builddir)/js/js-resources.c               \
+       $(top_builddir)/js/js-resources.h               \
+       $(NULL)
+gnome_shell_extension_prefs_CPPFLAGS = $(gnome_shell_cflags)
+gnome_shell_extension_prefs_LDADD = libgnome-shell-js.la
+
 ########################################
 
 libgnome_shell_js_la_SOURCES =         \
diff --git a/src/gnome-shell-extension-prefs.c b/src/gnome-shell-extension-prefs.c
new file mode 100644 (file)
index 0000000..fefa3be
--- /dev/null
@@ -0,0 +1,49 @@
+#include "config.h"
+
+#include <girepository.h>
+#include <gjs/gjs.h>
+
+int
+main (int argc, char *argv)
+{
+  const char *search_path[] = { "resource:///org/gnome/shell", NULL };
+  GError *error = NULL;
+  GjsContext *context;
+  int status;
+
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
+  g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR);
+
+  context = g_object_new (GJS_TYPE_CONTEXT,
+                          "search-path", search_path,
+                          NULL);
+
+  if (!gjs_context_define_string_array(context, "ARGV",
+                                       argc - 1, (const char**)argv + 1,
+                                       &error))
+    {
+      g_message("Failed to defined ARGV: %s", error->message);
+      g_error_free (error);
+
+      return 1;
+    }
+
+
+  if (!gjs_context_eval (context,
+                         "const Main = imports.extensionPrefs.main; Main.main(ARGV);",
+                         -1,
+                         "<main>",
+                         &status,
+                         &error))
+    {
+      g_message ("Execution of main.js threw exception: %s", error->message);
+      g_error_free (error);
+
+      return status;
+    }
+
+  return 0;
+}
diff --git a/src/gnome-shell-extension-prefs.in b/src/gnome-shell-extension-prefs.in
deleted file mode 100644 (file)
index a1690a6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-if [ -z "$GI_TYPELIB_PATH" ]; then
-    export GI_TYPELIB_PATH=@pkglibdir@
-else
-    export GI_TYPELIB_PATH=@pkglibdir@:$GI_TYPELIB_PATH
-fi
-
-if [ -z "$LD_LIBRARY_PATH" ] ; then
-    export LD_LIBRARY_PATH=@pkglibdir@
-else
-    export LD_LIBRARY_PATH=@pkglibdir@:$LD_LIBRARY_PATH
-fi
-
-@GJS_CONSOLE@ -I @pkgdatadir@/js -c "const Main = imports.extensionPrefs.main; Main.main(ARGV);" "$@"